#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    char A, B, C;
    cin >> A >> B>> C;
    sort(a, a + 3);
    cout << a[A - 'A'] <<" "<< a[B - 'A'] <<" "<< a[C - 'A'];
    return 0;

}